/* @(#)GSOraganizationScanQueryAction.java    V0.1
 *
 * Project: GS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   user 2006-2-14
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;


import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.bean.GSOrganizationBean;
import com.hitrust.gs.form.GSOrganizationScanQueryForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.page.ResultProcess;
import com.hitrust.gs.business.GSOrganizationProcessor;

/**
 * 查找到组织机构管理
 */
public class GSOrganizationScanQueryAction extends GSBaseAction{

    /* (non-Javadoc)
     * @see com.hitrust.gs.service.GSBaseAction#execute(com.hitrust.gs.service.GSBaseForm)
     */
    public String execute(GSBaseForm aForm) throws Exception {
        GSOrganizationScanQueryForm tForm = (GSOrganizationScanQueryForm)aForm;
        String tOrgId=tForm.getGsorgid()==null?"":tForm.getGsorgid().trim();
        String tOrgName=tForm.getGsorgname()==null?"":tForm.getGsorgname().trim();
        //通过机构编号和机构名称
        ArrayList tOraganization=GSOrganizationProcessor.queryManageOrg(tOrgId,tOrgName);
        
        ResultProcess tRsProc = new ResultProcess();
        ArrayList tList = new ArrayList();
        
        GSOrganizationBean tGSOrganizationBean=new GSOrganizationBean();
        if (tOraganization != null && tOraganization.size() > 0) {
            for (int i = 0; i < tOraganization.size(); i++) {
                tGSOrganizationBean = (GSOrganizationBean) tOraganization.get(i);
                String[] tStr = new String[11];
                tStr[0]=tGSOrganizationBean.getGs_org_id()==null?"无":tGSOrganizationBean.getGs_org_id();
                tStr[1]=tGSOrganizationBean.getGs_org_name()==null?"无":tGSOrganizationBean.getGs_org_name();
                tStr[2]=tGSOrganizationBean.getGs_org_addr()==null?"无":tGSOrganizationBean.getGs_org_addr();
                tStr[3]=tGSOrganizationBean.getGs_org_post()==null?"无":tGSOrganizationBean.getGs_org_post();
                tStr[4]=tGSOrganizationBean.getGs_org_phone()==null?"无":tGSOrganizationBean.getGs_org_phone();
                tStr[5]=tGSOrganizationBean.getGs_org_fax()==null?"无":tGSOrganizationBean.getGs_org_fax();
                tStr[6]=tGSOrganizationBean.getGs_principal_name()==null?"无":tGSOrganizationBean.getGs_principal_name();
                tStr[7]=tGSOrganizationBean.getGs_principal_email()==null?"无":tGSOrganizationBean.getGs_principal_email();
                tStr[8]=tGSOrganizationBean.getGs_principal_phone()==null?"无":tGSOrganizationBean.getGs_principal_phone();
                tStr[9]=tGSOrganizationBean.getGs_upper_orgId()==null?"无":tGSOrganizationBean.getGs_upper_orgId();
                tStr[10]=tGSOrganizationBean.getGs_is_stock()==null?"_":(tGSOrganizationBean.getGs_is_stock().equals("1")?"是":"否");
                tList.add(tStr);
            }
            tRsProc.setResult(tList);
            }
        tForm.getRequest().setAttribute("orgList", tRsProc);
        aForm.getRequest().setAttribute("requery","false");
        
		aForm.getRequest().setAttribute("s_gsorgid",tOrgId);
		aForm.getRequest().setAttribute("s_gsorgname",tOrgName);
        //tForm.getRequest().setAttribute("choice",tForm.getRequest().getParameter("choice"));
      
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
